package com.cs.bd.ad.bean;

import android.content.Context;

import com.cs.bd.ad.http.bean.BaseAppInfoBean;
import com.cs.bd.ad.http.bean.BaseModuleDataItemBean;
import com.cs.bd.ad.http.bean.BaseOnlineAdInfoBean;
import com.cs.bd.ad.http.bean.BaseOnlineModuleInfoBean;
import com.cs.bd.ad.sdk.bean.SdkAdSourceAdInfoBean;

import java.util.List;

public class AdModuleInfoBean {
    public static final int AD_TYPE_OFFLINE = 0;
    public static final int AD_TYPE_ONLINE = 1;
    public static final int AD_TYPE_SDK = 2;
    public static final int AD_TYPE_INTELL = 3;
    public static final int AD_OBJECT_TYPE_OFFLINE_ONLINEAPI = 0;
    public static final int AD_OBJECT_TYPE_FACEBOOK_BANNER = 1;
    public static final int AD_OBJECT_TYPE_FACEBOOK_INTERSTITIAL = 2;
    public static final int AD_OBJECT_TYPE_FACEBOOK_NATIVE = 3;
    public static final int AD_OBJECT_TYPE_ADMOB_BANNER = 4;
    public static final int AD_OBJECT_TYPE_ADMOB_INTERSTITIAL = 5;
    public static final int AD_OBJECT_TYPE_ADMOB_NATIVE = 6;
    public static final int AD_OBJECT_TYPE_LOOPME_BANNER = 7;
    public static final int AD_OBJECT_TYPE_LOOPME_INTERSTITIAL = 8;
    public static final int AD_OBJECT_TYPE_MOBILECORE = 9;
    public static final int AD_OBJECT_TYPE_VUNGLE = 10;
    public static final int AD_OBJECT_TYPE_APPLOVIN = 11;
    public static final int AD_OBJECT_TYPE_CHEETAH = 12;
    public static final int AD_OBJECT_TYPE_CS = 13;
    public static final int AD_OBJECT_TYPE_IRONSCR = 14;
    public static final int AD_OBJECT_TYPE_CHEETAH_VIDEO = 15;
    public static final int AD_OBJECT_TYPE_MOPUB = 16;
    private int mAdType;
    private BaseModuleDataItemBean mModuleDataItemBean;
    private List<AdInfoBean> mAdInfoList;
    private SdkAdSourceAdInfoBean mSdkAdSourceAdInfoBean;
    private List<BaseAppInfoBean> mOfflineAdInfoList;
    private List<BaseOnlineAdInfoBean> mOnlineAdInfoList;
    private BaseOnlineModuleInfoBean mOnlineModuleInfoBean;
    private List<Object> mCsAdInfoList;
    private Object mCsModuleInfoBean;
    private Object mIntellModuleBean;
    private boolean mIsRequestData = false;

    public AdModuleInfoBean() {
    }

    public int getVirtualModuleId() {
        return this.mModuleDataItemBean != null ? this.mModuleDataItemBean.getVirtualModuleId() : -1;
    }

    public int getAdType() {
        return this.mAdType;
    }

    public List<AdInfoBean> getAdInfoList() {
        return this.mAdInfoList;
    }

    public void setAdInfoList(List<AdInfoBean> adInfoList) {
        this.mAdInfoList = adInfoList;
    }

    public SdkAdSourceAdInfoBean getSdkAdSourceAdInfoBean() {
        return this.mSdkAdSourceAdInfoBean;
    }

    public void setSdkAdSourceAdInfoBean(SdkAdSourceAdInfoBean sdkAdSourceAdInfoBean) {
        this.mSdkAdSourceAdInfoBean = sdkAdSourceAdInfoBean;
    }

    public List<BaseAppInfoBean> getOfflineAdInfoList() {
        return this.mOfflineAdInfoList;
    }

    public void setOfflineAdInfoList(Context context, BaseModuleDataItemBean moduleDataItemBean, List<BaseAppInfoBean> offlineAdInfoList) {
        this.mAdType = 0;
        this.mModuleDataItemBean = moduleDataItemBean;
        this.mOfflineAdInfoList = offlineAdInfoList;
        this.setExtraInfos(moduleDataItemBean);
    }

    public List<BaseOnlineAdInfoBean> getOnlineAdInfoList() {
        return this.mOnlineAdInfoList;
    }


    public void setOnlineAdInfoList(Context context, BaseModuleDataItemBean moduleDataItemBean, BaseOnlineModuleInfoBean onlineModuleInfoBean, List<BaseOnlineAdInfoBean> onlineAdInfoList, List<String> installFilterException) {
        this.mAdType = 1;
        this.mModuleDataItemBean = moduleDataItemBean;
        this.mOnlineModuleInfoBean = onlineModuleInfoBean;
        this.mOnlineAdInfoList = onlineAdInfoList;
        this.setExtraInfos(moduleDataItemBean);
    }

    private void setExtraInfos(BaseModuleDataItemBean moduleDataItemBean) {
        if (this.mAdInfoList != null && moduleDataItemBean != null) {
            for(int i = 0; i < this.mAdInfoList.size(); ++i) {
                ((AdInfoBean)this.mAdInfoList.get(i)).setOnlineAdvType(moduleDataItemBean.getOnlineAdvType());
            }
        }

    }

    public BaseModuleDataItemBean getSdkAdControlInfo() {
        return this.mModuleDataItemBean;
    }

    public void setSdkAdControlInfo(BaseModuleDataItemBean moduleDataItemBean) {
        this.mAdType = 2;
        this.mModuleDataItemBean = moduleDataItemBean;
    }

    public void setFakeFbNativeControlInfo(BaseModuleDataItemBean moduleDataItemBean, List<AdInfoBean> adInfoList) {
        this.mAdType = 0;
        this.mAdInfoList = adInfoList;
        moduleDataItemBean.setAdvDataSourceType(Integer.parseInt("0"));
        this.mModuleDataItemBean = moduleDataItemBean;
    }

    public BaseModuleDataItemBean getModuleDataItemBean() {
        return this.mModuleDataItemBean;
    }

    public BaseOnlineModuleInfoBean getOnlineModuleInfoBean() {
        return this.mOnlineModuleInfoBean;
    }

    public boolean isRequestData() {
        return this.mIsRequestData;
    }

    public void setIsRequestData(boolean isRequestData) {
        this.mIsRequestData = isRequestData;
    }

    public static boolean isFaceBookAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && (moduleDataItemBean.getAdvDataSource() == 2 || moduleDataItemBean.getAdvDataSource() == 11);
    }

    public static boolean isAdMobAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 8;
    }

    public static boolean isMobileCoreAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && (moduleDataItemBean.getAdvDataSource() == 9 || moduleDataItemBean.getAdvDataSource() == 10);
    }

    public static boolean isLoopMeAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 16;
    }

    public static boolean isVungleAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 34;
    }

    public static boolean isApplovinAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 20;
    }

    public static boolean isCheetahAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 21;
    }

    public static boolean isCsAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 35;
    }

    public static boolean isS2SAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 36;
    }

    public static boolean isIronScrAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 37;
    }

    public static boolean isMoPubAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 39;
    }

    public static boolean isCheetahVideoAd(BaseModuleDataItemBean moduleDataItemBean) {
        return moduleDataItemBean != null && moduleDataItemBean.getAdvDataSource() == 38;
    }

    public static boolean isContainFaceBookAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && (advDataSourceList.contains(2) || advDataSourceList.contains(11));
    }

    public static boolean isContainAdMobAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && advDataSourceList.contains(8);
    }

    public static boolean isContainMobileCoreAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && (advDataSourceList.contains(9) || advDataSourceList.contains(10));
    }

    public static boolean isContainLoopMeAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && advDataSourceList.contains(16);
    }

    public static boolean isContainVungleAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && advDataSourceList.contains(34);
    }

    public static boolean isContainApplovinAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && advDataSourceList.contains(20);
    }

    public static boolean isContainCheetahAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && advDataSourceList.contains(21);
    }

    public static boolean isContainCheetahVideoAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && advDataSourceList.contains(38);
    }

    public static boolean isContainCsAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && advDataSourceList.contains(35);
    }

    public static boolean isContainIronScrAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && advDataSourceList.contains(37);
    }

    public static boolean isContainMoPubAdSource(List<Integer> advDataSourceList) {
        return advDataSourceList != null && advDataSourceList.contains(39);
    }

    public static boolean isSupportFacebookAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        if (BaseModuleDataItemBean.isBannerAd(moduleDataItemBean)) {
            return isContainValue(supportAdObjectTypes, 1);
        } else {
            return BaseModuleDataItemBean.isInterstitialAd(moduleDataItemBean) ? isContainValue(supportAdObjectTypes, 2) : isContainValue(supportAdObjectTypes, 3);
        }
    }

    public static boolean isSupportAdmobAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        if (!BaseModuleDataItemBean.isBannerAd(moduleDataItemBean) && !BaseModuleDataItemBean.isBannerAd300_250(moduleDataItemBean)) {
            return BaseModuleDataItemBean.isInterstitialAd(moduleDataItemBean) ? isContainValue(supportAdObjectTypes, 5) : isContainValue(supportAdObjectTypes, 6);
        } else {
            return isContainValue(supportAdObjectTypes, 4);
        }
    }

    public static boolean isSupportLoopmeAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        if (BaseModuleDataItemBean.isBannerAd(moduleDataItemBean)) {
            return isContainValue(supportAdObjectTypes, 7);
        } else {
            return BaseModuleDataItemBean.isInterstitialAd(moduleDataItemBean) ? isContainValue(supportAdObjectTypes, 8) : false;
        }
    }

    public static boolean isSupportMobileCoreAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        return isContainValue(supportAdObjectTypes, 9);
    }

    public static boolean isSupportVungleAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        return isContainValue(supportAdObjectTypes, 10);
    }

    public static boolean isSupportApplovinAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        return isContainValue(supportAdObjectTypes, 11);
    }

    public static boolean isSupportCheetahAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        return isContainValue(supportAdObjectTypes, 12);
    }

    public static boolean isSupportCheetahVideoAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        return isContainValue(supportAdObjectTypes, 15);
    }

    public static boolean isSupportCsAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        return isContainValue(supportAdObjectTypes, 13);
    }

    public static boolean isSupportIronScrAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        return isContainValue(supportAdObjectTypes, 14);
    }

    public static boolean isSupportMoPubAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        return isContainValue(supportAdObjectTypes, 16);
    }

    public static boolean isSupportOfflineOnlineapiAdObjectType(BaseModuleDataItemBean moduleDataItemBean, int[] supportAdObjectTypes) {
        return isContainValue(supportAdObjectTypes, 0);
    }

    public static boolean isContainValue(int[] values, int value) {
        if (values == null) {
            return false;
        } else {
            int[] var2 = values;
            int var3 = values.length;

            for(int var4 = 0; var4 < var3; ++var4) {
                int item = var2[var4];
                if (item == value) {
                    return true;
                }
            }

            return false;
        }
    }
}